﻿package Levels 
{
	import adobe.utils.CustomActions;
	import flash.display.MovieClip;
	import Objetos.Heroi;
	import Objetos.Inimigo;
	import Objetos.Plataforma;
	import Objetos.Portal;
	/**
	 * ...
	 * @author ...
	 */
	public class Level1 extends Level
	{
		
		public function Level1() 
		{
			
		}
		
		public function desenharTela():void 
		{
		
			gameConstructor = new Fase1();
			gameConstructor.x = 0;
			gameConstructor.y = 0;
			Main.getInstance().MC_tela.addChild(gameConstructor);
			
			MC_heroi = new Heroi();
			MC_heroi.x = 100;
			MC_heroi.y = 100;
			Main.getInstance().MC_tela.addChild(MC_heroi);
			//AR_herois.push(MC_heroi);
			
			MC_inimigo = new Inimigo(750);
			MC_inimigo.y = 100;
			Main.getInstance().MC_tela.addChild(MC_inimigo);
			//AR_inimigos.push(MC_inimigo);
			
			MC_portal = new Portal();
			MC_portal.x = 780;
			MC_portal.y = 400;
			Main.getInstance().MC_tela.addChild(MC_portal);
			
			MC_portalEnd = new Portalv();
			MC_portalEnd.x = 891;
			MC_portalEnd.y = 147;
			Main.getInstance().MC_tela.addChild(MC_portalEnd);
		}
		
		public function desenharArray():void
		{
			for (var z:int = 0; z < gameConstructor.numChildren; z++)
			{
				var plat:Object = gameConstructor.getChildAt(z);
				
				if (plat is Plataforma)
				{
					AR_plat.push(plat);
				}
			}
			
			trace(AR_plat.length);
		}
		
		override public function update():void 
		{
			super.update();
			
			if (MC_heroi != null)
			{
				if (MC_heroi.hitTestObject(MC_portal))
				{
					MC_heroi.x = 700;
					MC_heroi.y = 100;
				}
				
				if (MC_heroi.hitTestObject(MC_portalEnd))
				{
					Main.getInstance().removerFase();
					Main.getInstance().criarFase("Level2");					
				}
			}
		}
	}

}